perf(examples): async_date_timerfd on the new stdlib time APIs + README#92
Draft
enghitalo wants to merge 1 commit into
Draft
perf(examples): async_date_timerfd on the new stdlib time APIs + README#92enghitalo wants to merge 1 commit into
enghitalo wants to merge 1 commit into
Conversation
Refactor the example as if vlang/v#27639/#27641/#27642 were merged (they are open; V must be built from those branches until then): - rebuild() is now 3 lines: time.unix_now() (~2 ns wall-clock read) + time.update_http_header (in-place incremental refresh, ~2 ns within the same minute; calendar math only on day rollover). The hand-rolled bucket logic, digit writer and name tables (~55 lines) moved to vlib, where they are oracle-tested across every rollover. - The timerfd declarations come with `import time`: no local fn C. decls, and arm_periodic builds a typed C.itimerspec instead of a raw [4]i64; the tick drains into a named u64 expiration count. - date_line_len stays a literal 37: a fixed-array size computed from another module's const trips the checker in _test.v builds — the relationship to time.http_header_len is pinned by a test instead. - New README with a mermaid flow of the whole model (one loop, two event kinds), the byte layout of the cached line, the cost table and the contrast with date_header/efficient_date. Verified on a patched toolchain: 3/3 tests, -prod build, live server with Date advancing under zero load. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactors
examples/async_date_timerfdas if the three upstream V PRs were merged, and adds a README with a mermaid flow of the whole model.rebuild()collapses to 3 lines:time.unix_now()(~2 ns) +time.update_http_header(~2 ns within the same minute; full reformat only on day rollover). The ~55 lines of hand-rolled bucket logic, digit writer and name tables moved to vlib, oracle-tested there.import timebrings thetimerfddeclarations: no localfn C.decls, typedC.itimerspecinstead of a raw[4]i64, and the tick drains into a namedu64expiration count.date_header/efficient_date.Depends on (do not merge until these land in V master)
time.write_http_header+time.update_http_headertime.unix_now()timemoduleThe example is not in the CI matrices, so this cannot break CI either way — the draft state is about not landing an example that requires an unreleased toolchain.
Verification (patched local toolchain)
date_line_len == 6 + time.http_header_len + 2(the fixed-array size stays a literal: cross-module const arithmetic in a fixed-array size trips the checker in_test.vbuilds — V bug worth filing separately).-prodbuild clean; live server:Dateadvanced12:05:15 → 12:05:17under zero load.v check-mdclean on the README.🤖 Generated with Claude Code